import {openModal} from '@/utils/index.js';
import StartNodeConfiguration from '@/components/flow/nodeConfiguration/StartNodeConfiguration.vue';
import FlowModelInstance from '@/components/flow/typs/FlowModelInstance.js';
import EndNodeConfiguration from '@/components/flow/nodeConfiguration/EndNodeConfiguration.vue';

export default class EditEndNodeCommand {
  constructor(supportInstance, nodeId) {
    this.supportInstance = supportInstance;
    this.nodeId = nodeId;
  }

  serve() {
    let flowModelInstance = new FlowModelInstance(this.supportInstance.getModel());
    let endNode = flowModelInstance.getEndNode();
    openModal(EndNodeConfiguration, {endNode, flowModelInstance, service: this.supportInstance.service}, (startNode) => {
      flowModelInstance.replaceNode(startNode);
      this.supportInstance.setModel(flowModelInstance.getModelString());
    });
  }
}